<?php

namespace IDock\Insurance\ZMBX\Request;

use IDock\Insurance\ZMBX\Request\AllZMBXRequest;
use IDock\Insurance\ZMBX\Response\EPolicyDownloadResponse;
use IDock\Visitor\EPolicyDownloadVisitor;

class EPolicyDownloadRequest extends AllZMBXRequest
{
    protected $route = 'InsurancePolicyPrint.do';

    public $requestCode  = 'InsurancePolicyPrint';

    protected $response = EPolicyDownloadResponse::class;

    protected $urlTip = '电子保单下载';

    /**
     * @var  EPolicyDownloadVisitor $visitor
     */
    protected $visitor;

    public function generate(): array
    {
        $this->setZMBXToken($this->visitor->argc);
        $policy = $this->visitor->policyNo;

        $riskCode = '';
        $businessType = 'P';
        $documentType = 'DZ_AE';

        switch ($this->visitor->argc['type'] ?? '') {
            case 'ci':
                $riskCode = '0330';
                break;
            case 'bi':
                $riskCode = '0361';
                break;
            case 'nc':
                $businessType = 'EP';
                break;
            case 'sign':
                $riskCode = '0330';
                $documentType = 'DZ_AJ';
                break;
        }

        return [
            'policyNo' => $policy,
            'riskCode' => $riskCode,
            'businessType' => $businessType,//车险保单下载传P 非车险保单下载传EP
            'documentType' => $documentType,
            'endorSeqNo' => '000',
        ];
    }
}
